package com.pansky.crm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pansky.crm.common.mybatisplus.ApiResult;
import com.pansky.crm.entity.Employee;
import com.pansky.crm.service.EmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：zhouzhiyong
 * @date ：Created in 2021/2/25 15:26
 * @description：RoleEmployeeService
 */
@Service
@Slf4j
public class RoleEmployeeService {

    @Autowired
    private EmployeeService employeeService;

//    /**
//     * 通过角色id，分页获取成员员工列表
//     *
//     * @param roleId
//     * @return
//     */
//    public ApiResult<IPage<Employee>> listEmployeeByName(String roleId, Integer currentPage, Integer pageSize) {
//        IPage<Employee> page = new Page<>(currentPage, pageSize);
//        QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
//        queryWrapper.eq("role_id", roleId);
//        IPage<Employee> employeeIPage = employeeService.page(page, queryWrapper);
//        return ApiResult.ok(employeeIPage);
//    }


    public ApiResult<List<Employee>> getAllEmployeeByRoleId(Integer roleId) {
        QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_id", roleId);
        List<Employee> employees = employeeService.list(queryWrapper);
        return ApiResult.ok(employees);
    }
}
